<!DOCTYPE html>
<html>

<head>

  
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
 <link rel="shortcut icon" href="favicon.ico">
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    
    <style>
        .hide_table{display: none;}
    </style>
</head>

<body style="color:#333;padding:3px;">
    <!-- 标题 -->
     <form method="post" class="form-horizontal" enctype="multipart/form-data" id="f1">
        <input type="hidden" name="type" id="type"/>
        <input type="hidden" name="tid" value="{$apply.id}"/>
      <div class="page-heade">
       <h2 class="title_color text-center">经销商销售目标修改</h2>
    </div>
    <!-- 标题 -->
    <div class="form-horizontal">
      <table class="row-margin-top tab-content table-bordered table text-center" border="1">
           <tr>
            <td style="width:150px">主题：</td>
            <td class="text-left" ><input type="text" class="form-control" value="{$apply.title}" name="title"/></td>
          </tr>
        
           <tr>
            <td style="width:150px">申请单编号：</td>
            <td class="text-left" >{$apply.no}</td>
          </tr>

          <tr>
            <td colspan="2" class="text-left">
              <input type="button" class="btn btn-w-m btn-info" id="dr" value="导入数据"/>
                    
                  <span>(至少导入一条预算明细)</span>
               <input type="button" class="btn btn-w-m btn-info" id="dc" tid="{$apply.id}" value="导出数据"/>
            </td>
          </tr>
             <tbody id="tb" style="display:none;">
              <tr>
                 <td class="text-left">
                 选择导入的文件:
                 </td>
                 <td><input type="file" name="wenjian" id="drfile"/></td>
              </tr>
              <tr>
                   <td colspan="2" class="text-left" style="font-size: 12px;">
                   <span style="color:red;">温馨提示:如果导入过程中出现未满足系统要求的数据，则整份导入资料都无法导入，必须按照系统给出的信息提示修改导入资料，并重新上传</span><br/>
                   <b>Excel文件注意事项:</b><br/>
                   1.请仔细阅读下面的TI销售目标导入格式，并按照注意事项填入正确的数据<br/>
                   
                   2.经销商不能为空，且必须是系统中存在的经销商<br/>
                  
                   3.若设置品牌，则品牌不能为空，且必须是系统中存在的品牌<br/>
                   4.若设置品类，则品类不能为空，且必须是系统中存在的品类<br/>
                   5.若设置系列，则系列不能为空，且必须是系统中存在的系列<br/>
                  
                   6.若设置财年，则财年不能为空，且必须是系统中存在的财年<br/>
                   7.若设置一级考核期，则一级考核期不能为空，且必须是系统中存在的一级考核期<br/>
                   8.若设置二级考核期，则二级考核期不能为空，且必须是系统中存在的二级考核期<br/>
                   9.目标金额不能为空，且必须是系统中存在的经销商<br/>
                  
                   <b>Excel文件导入格式:</b><a href="{:url('Xitongexcel/jingxiaoshang_daochu')}">经销商销售目标导入格式.xls</a><span style="color:red;">Excel中标记为红色底色的列都为必填项</span>
                   </td>
              </tr>
          </tbody>
          <tr>
            <td colspan="2" class="text-left">
              <label style="padding-top: 0" class="col-sm-1 control-label">备注：</label>
                  <div class="col-sm-10">
                      <textarea style="height: 100px;" maxlength="500" name="remark" class="form-control">{$apply.remark}</textarea>
                  </div>
            </td>
          </tr>
      </table>
      <div class="container-fluid">
        <a href="javascript:;" class="btn btn-outline btn-primary cbtn" onclick="fanka(0)">查看详情</a>
         <a href="javascript:;" class="btn btn-outline btn-primary cbtn" onclick="fanka(1)">明细汇总</a>
      
        
      <!--详情-->
         <table class="table row-margin-top table-bordered bud_hei table-hover hide_table">
            <tr class="info">
                <th>明细编号</th>
              
               <th>经销商</th>
               <th>产品品牌</th>
              
                <th>财年</th>
                <th>一级考核期</th>
               <th>二级考核期</th>
                <th>目标金额(元)</th>
               
            </tr>
     		{volist name="detail" id="vod"}
     			<tr>
					<td>{$apply.no}_{$vod.detail_no}</td>
					<td>{$vod.jingxiao}</td>
					<td>{$vod.pinpai}</td>
					<td>{$vod.cainian}</td>
					<td>{$vod.yijikaoheqi}</td>
					<td>{$vod.erjikaoheqi}</td>
					<td>{$vod.feiyong}</td>
     			</tr>
     		{/volist}
      </table> 
      <!--详情-->
      <!--产品-->
         <table class="table row-margin-top table-bordered bud_hei hide_table">
          <tr class="info text-center">
            <th>经销商</th>
       		<th>品牌</th>
       		{volist name="ck" id="vock"}
            	<th>{$vock.kaoheqi}({$vock.cainian})</th>
            {/volist}
            <th>合计</th>
          </tr>
 
         
          {volist name="huizong" id="voq"}
          	<tr>
          		{if $voq.hang neq 0}
          		<td rowspan="{$voq.hang}" class=''>{$voq.jingxiao}</td>
          		{/if}
				<td>{$voq.pinpai}</td>
				{volist name="ck" id="voc1"}
					<td>
            		{volist name="huizongde" id="voqd1"}
            			{if condition="($voqd1.jingxiao eq $voq.jid) and ($voqd1.pinpai eq $voq.pid) and ($voqd1.cainian eq $voc1.cid) and ($voqd1.kaoheqi eq $voc1.kid)"}
            			{$voqd1.f}
            			{/if}
            		{/volist}
            		</td>
            	{/volist}
            	<td>{$voq.f}</td>
          	</tr>
          {/volist}
          <tr class="warning">
            <td class="text-left"  colspan="{$kc+1}" headers="">预算总计：</td>
            <td>{$sumhuizong}</td>
          </tr>
          
      </table>
      <!--产品-->
   
      
       <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                   {volist name="fujian" id="fo"}
                        <h4>{$fo.file_name}</h4>
                   {/volist}
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach"  value="{$apply.fujian}"  >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
      
       <div class="hr-line-dashed"></div>
              <div class="container-fluid text-center">
                <input class="btn btn-w-m btn-warning" type="button" id="caogao" value="保存为草稿">
                <input class="btn btn-w-m btn-primary" type="button" id="tijiao" value="保存并提交流程">
                <input class="btn btn-w-m btn-default" type="button" id="back" name="" value="返回">
              </div>
    </div>
       {if condition="$apply.tag eq 1"}
       <div class="SuccessImg font-bold">
        申报已异动
      </div>
    {/if}
     {if condition="$apply.tag neq 1 and $apply.state eq 7"}
        <div class="applyImg font-bold">
        申报已生效
      </div>
    {/if}
     </form>

    </div>
    
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <!-- <script src="js/plugins/layer/layer.min.js"></script> -->

    <!-- 自定义js -->
    <!-- <script src="js/hplus.js?v=4.1.0"></script> -->
    <!-- <script type="text/javascript" src="js/contabs.js"></script> -->
     <!-- Peity -->
    <script src="__STATIC__/layout/js/plugins/peity/jquery.peity.min.js"></script>

    <!-- jqGrid -->
    <script src="__STATIC__/layout/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
    <script src="__STATIC__/layout/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>

    <!-- 自定义js -->
    <script src="__STATIC__/layout/js/content.js?v=1.0.0"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
    
    <!-- ztree -->
    <script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.excheck.js"></script>
    <!-- <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> -->
    <!--统计代码，可删除-->
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
    <script>
    var fr={$from};
     //提交处理
        $("#caogao").click(function(){
          //保存类型设为草稿
          $("#type").val(1);
           
           
                go_submits();
                
        })
        $("#tijiao").click(function(){
          //保存类型设为草稿
          $("#type").val(3);
          
                go_submits();
              
        })
          //ajax提交
        function go_submits(){
           var formData = new FormData($('#f1')[0]);  
         $.ajax({    
              url: '{:url("xg_jt_add")}' ,  /*这是处理文件上传的servlet*/  
              type: 'POST',    
              data: formData,   
              cache: false,    
             contentType: false,  
              processData: false,  
              success: function (re) {  
             // alert(re);  
                 if(re!=""){
                var jieguo=JSON.parse(re);
                  if(jieguo["state"]==1){
                    swal({
              title: "完成",
              text:  jieguo["msg"],
              type: "success"
              },function(){
                if(fr==1)
                  location.href="{:url('allmanage')}";
                else
                  location.href="{:url('allshumanage')}";
              });
                  }else{
                  swal({
            title: "错误",
            text:  jieguo["msg"],
            type: "warning"
            });
                  }
                  
                }else{
                   swal({
            title: "错误",
            text:  "系统繁忙请稍后再试",
            type: "warning"
            });
                }
              },    
              error: function (re) {    
                  swal({
            title: "错误",
            text:  "系统繁忙请稍后再试",
            type: "warning"
            });
              }    
         });    
        }
      $("#back").click(function(){
        if(fr==1)
                  location.href="{:url('allmanage')}";
                else
                  location.href="{:url('allshumanage')}";
    })
   $("#dr").click(function(){
      $("#tb").show();
    })
    $("#dc").click(function(){
      location.href="{:url('daochu')}?tid="+$(this).attr("tid");
    })
        //默认第一个选项卡选中
        $(".cbtn").eq(0).addClass("active");
        $(".hide_table").eq(0).show();

        function fanka(i){
            $(".cbtn").removeClass("active");
            $(".hide_table").hide();

            $(".cbtn").eq(i).addClass("active");
            $(".hide_table").eq(i).show();
        }
        $(".ned_td").each(function(){
          var index=$(this).attr("tag");
          var he=0;
          $(".ned_tr").each(function(){
            if(!isNaN(parseFloat($(this).children().eq(index).html())))
              he+=parseFloat($(this).children().eq(index).html());
          })
          $(this).html(he);
        })
         $(".nef_td").each(function(){
          var index=$(this).attr("tag")*1+1;
          var he=0;
          $(".nef_tr").each(function(){
            if(!isNaN(parseFloat($(this).children().eq(index).html())))
              he+=parseFloat($(this).children().eq(index).html());
          })
          $(this).html(he);
        })
           $(".neq_td").each(function(){
          var index=$(this).attr("tag");
          var he=0;
          $(".neq_tr").each(function(){
            if(!isNaN(parseFloat($(this).children().eq(index).html())))
              he+=parseFloat($(this).children().eq(index).html());
          })
          $(this).html(he);
        })
            $(".nec_td").each(function(){
          var index=$(this).attr("tag");
          var he=0;
          $(".nec_tr").each(function(){
            if(!isNaN(parseFloat($(this).children().eq(index).html())))
              he+=parseFloat($(this).children().eq(index).html());
          })
          $(this).html(he);
        })
    </script>
    <script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script type="text/javascript">
   // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [{if $apply.fujian}value="{$apply.fujian}"{/if} ];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });
     })

</script>
</body>

</html>
